package com.four.collage.controller;

import com.four.collage.dao.GroupmanageMapper;
import com.four.collage.entity.Groupmanage;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author:wsy
 * @Date: 2021/12/19/11:18
 * @Description
 */
@Component
public class RabbitController {

    @Autowired
    private GroupmanageMapper groupmanageMapper;

    @RabbitListener(queues = "order-consume")
    @RabbitHandler
    public void getMsg(Integer groId){
        System.out.println(groId);
        Groupmanage groupmanage=groupmanageMapper.getGroupmanageById(groId);
        if(groupmanage.getGroParticipateNum()<groupmanage.getGroPeopleNum()){
            //1.拼团失败
            int ststus=1;
            groupmanageMapper.updGeoupmanageStatus(ststus,groId);
        }else if(groupmanage.getGroParticipateNum().equals(groupmanage.getGroPeopleNum())){
            int status=2;
            groupmanageMapper.updGeoupmanageStatus(status,groId);
        }
    }
}
